<form class="form-horizontal" name="profileForm" ng-submit="$modal.ok()" novalidate>
    <div class="modal-header bg-primary">
        <h3 class="modal-title">{{$modal.isEdit ? 'Update' : 'Add'}} profile</h3>
    </div>
    <div class="modal-body">
        <div class="form-group">
            <label class="col-sm-3 control-label">
                Profile type
                <i class="fa fa-asterisk text-danger"></i>
            </label>
            <div class="col-sm-9">
                <div class="btn-group">
                    <label class="btn btn-primary" ng-model="$modal.formData.isAdmin" uib-btn-radio="true">Administration Profile</label>
                    <label class="btn btn-primary" ng-model="$modal.formData.isAdmin" uib-btn-radio="false">Organisation Profile</label>
                </div>
                <p class="help-block">{{$modal.permissions[$modal.formData.isAdmin ? 'admin' : 'org'].hints}}</p>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">
                Name
                <i class="fa fa-asterisk text-danger"></i>
            </label>
            <div class="col-sm-9">
                <input class="form-control" name="name"
                    ng-disabled="$modal.isEdit"
                    ng-model="$modal.formData.name"
                    required type="text">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">
                Permissions
                <i class="fa fa-asterisk text-danger"></i>
            </label>
            <div class="col-sm-9">
                <select class="form-control" ng-model="$modal.formData.permissions"
                    ng-options="permission as ($modal.permissions[$modal.formData.isAdmin ? 'admin' : 'org'].labels[permission]) for permission in $modal.permissions[$modal.formData.isAdmin ? 'admin' : 'org'].keys" multiple size="15">
                </select>
                <div class="wrap">
                    Selected ({{$modal.formData.permissions.length || 0}})
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer text-left">
        <button class="btn btn-default" ng-click="$modal.cancel()" type="button">Cancel</button>
        <span class="hpad10">
            <i class="fa fa-asterisk text-danger"></i>&nbsp;Required field</span>
        <button class="btn btn-primary pull-right" ng-disabled="profileForm.$invalid" type="submit">Save profile</button>
    </div>
</form>
